#!/usr/bin/python
'''
names repeats in file or stdin.
'''
import sys

# parameters.
codex = sys.argv[1]
in_file = False
if len(sys.argv) == 3:
	in_file = sys.argv[2]
	
	
# read in lines from file.
if in_file != False:
	fin = open(in_file, "rb")
	lines = fin.readlines()
	fin.close()
	
else:
	lines = sys.stdin.readlines()
	

# load info.
abc = {}
fin = open(codex,"rb")
for line in fin:
	tmp = line.strip().split()
	abc[tmp[0]] = tmp[1]
	
# name lines
for line in lines:
	tmp = line.strip()
	
	if tmp in abc:
		print "%s\t%s" % (tmp, abc[tmp])
	else:
		print "missing", tmp
		sys.exit()
	
